<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html"  prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"   prefix="c" %>
<%@page import="java.util.List"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/ui.jqgrid.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/redmond/jquery-ui-1.8.2.custom.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/operhc_style.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/buttonOHC.css" />
	
	<script type="text/javascript" src='<%= request.getContextPath()%>/dwr/interface/AdminAction.js'></script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/util.js'></script>
	<script src="<%=request.getContextPath()%>/js/util/gridUtil.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery-1.7.1.js" type="text/javascript"></script>	
	<script src="<%=request.getContextPath()%>/js/i18n/grid.locale-es.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/jquery.jqGrid.src.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/grid.subgrid.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/util/encabezado.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/js/util/formatters.js" type="text/javascript"></script>
	
</head>

<script type="text/javascript" charset="UTF-8">

var arrySimula   = new Array();
var arryMultCont = new Array();
var arryContrata = new Array();
var arryNivela   = new Array();
var arrSegmentos = new Array();

var idTableProduct = 'listProducts';
var idTableSegmento = 'listSegmentos';

var lastSel = '';
var lastSelSegmento = '';

var rutaContexto1 = location.pathname;
var rutaContexto2 = "<%=request.getContextPath()%>";
var rutaContexto  = rutaContexto1.substr(0, rutaContexto1.indexOf(rutaContexto2)) + rutaContexto2;

var myColNames  = ['','Codigo Producto HC', 'Producto', 'Nivela', 'Mult. Cont.', 'Simula', 'Contrata', 'Codigo Producto Banco'];
var myDataModel = [ {name : 'codProductoHdn',	index : 'codProductoHdn',	width : VAL_WIDTH.SMALL, 	editable:true, editrules: {edithidden:true, required:true}, hidden:true, formatter: codProdFormat, unformat: genericUnFormat},
                    {name : 'codProducto',		index : 'codProducto' , 	width : VAL_WIDTH.SMALL, 	editable:true, edittype:'text', 	editoptions: {size:23, maxlength: 10, style: 'text-transform: uppercase'},  editrules: {required: true}},
                    {name : 'desProducto',		index : 'desProducto' ,		width : VAL_WIDTH.MED, 	 	editable:true, edittype:'text', 	editoptions: {size:40, maxlength: 255}, editrules: {required: true}},
                    {name : 'nivelaOferta',		index : 'nivelaOferta', 	width : VAL_WIDTH.SMALL,	editable:true, edittype:'checkbox', align:'center', formatter: nivelaFormat, 	unformat: genericCheckUnFormat},
                    {name : 'multCont',			index : 'multCont', 		width : VAL_WIDTH.SMALL,	editable:true, edittype:'checkbox', align:'center', formatter: multContFormat, 	unformat: genericCheckUnFormat},
                    {name : 'simula',			index : 'simula', 			width : VAL_WIDTH.SMALL,	editable:true, edittype:'checkbox', align:'center', formatter: simulaFormat, 	unformat: genericCheckUnFormat},
                    {name : 'contrata',			index : 'contrata', 		width : VAL_WIDTH.SMALL,	editable:true, edittype:'checkbox', align:'center', formatter: contrataFormat, 	unformat: genericCheckUnFormat},
                    {name : 'familia',			index : 'familia',	 		width : VAL_WIDTH.SMALL,	editable:true, edittype:'text', 	editoptions: {size:23, maxlength: 2,  style: 'text-transform: uppercase'},  editrules: {required: true}}
                   ];

var myColNamesSegmento  = ['','Codigo', 'Descripcion', 'Activo'];
var myDataModelSegmento = [{name : 'codSegmentoHdn',		index : 'codSegmentoHdn',		width : VAL_WIDTH.SMALL, 	editable:true, editrules: {edithidden:true, required:true}, hidden:true, formatter: codSegmentoFormat, unformat: genericUnFormat},
                    	   {name : 'codSegmento',			index : 'codSegmento' , 		width : VAL_WIDTH.SMALL, 	editable:true, edittype:'text', 	editoptions: {size:23, maxlength: 10, style: 'text-transform: uppercase'},  editrules: {required: true}},
                    	   {name : 'desSegmento',			index : 'desSegmento' ,			width : VAL_WIDTH.MED, 	 	editable:true, edittype:'text', 	editoptions: {size:40, maxlength: 255}, editrules: {required: true}},
                    	   {name : 'seleccionSegmento',		index : 'seleccionSegmento', 	width : VAL_WIDTH.SMALL,	editable:true, edittype:'checkbox', align:'center', formatter: checkSegmentoAdminFormat, unformat: genericCheckUnFormat, sortable: false}];

if (jQuery.browser.msie){
	document.getElementsByName = function(name, tag){
	    return getElementsByName_iefix(name, tag);
	};
}

//frk: si damos agregar y luego ESC se debe eliminar la fila agregada
$(document).keyup(function(e) {
  //frk: se presiono el ESC
  var tecla = (document.all) ? e.keyCode : e.which; 
  if (tecla == 27) {
	  lastSel = '';
	  lastSelSegmento = '';
	  deleteTblRowAdded('listProducts');
	  deleteTblRowAdded('listSegmentos');
  }else{
	  
	var codSegmento = document.getElementsByName("codSegmento")[0];
  	var codProducto = document.getElementsByName("codProducto")[0];
  	var familia = document.getElementsByName("familia")[0];
  	
	if(codProducto != undefined){
		codProducto.value = codProducto.value.toUpperCase();
	}
	
	if(codSegmento != undefined){
		codSegmento.value = codSegmento.value.toUpperCase();
	}
	
	if(familia != undefined){
		familia.value = familia.value.toUpperCase();
	}
  }
});

function consultarProductos(operation, message){

	jQuery("#listProducts").GridUnload();
	AdminAction.consultarProductosAjax(function(data){
		
		mostrarTabla(data);
		if(operation == 'logicDelete'){
			alert(message);
		}
	});
}

function consultarSegmentos(operation, message){

	jQuery("#listSegmentos").GridUnload();
	AdminAction.consultarSegmentosAjax(function(data){
		
		mostrarTablaSegmentos(data);
		if(operation == 'logicDelete'){
			alert(message);
		}
	});
}

function mostrarTabla(data){
	
	var idTableForm = 'listProducts';
	$('body').append('<div id="paginador_listProducts" class="grid"></div>'); 
	var paginador = "paginador_listProducts";
	
	jQuery("#"+idTableForm).jqGrid(
	{
		beforeSelectRow: function(){},
		afterInsertRow: function(id, rowdata, rowelem){
			
			if(id == undefined){
				jQuery("#"+idTableForm).jqGrid('editRow', id,
		        { 
	       		    keys : true,
	       		    restoreAfterError : true,
	       		    errorfunc: function(rowid, response) {
	       		    	
	      		    	var mensaje = response.responseText;
	      		    	deleteTblRowAdded(idTableForm);
	      		    	
	   		    		if (mensaje != "" && mensaje != undefined) {
	   		    			setTimeout("alert('"+mensaje+"','Cerrar',{left:460})", 250);        		    			
  		    		    }else{
  		    		    	setTimeout("alert('Ocurrió un error al intentar guardar la información.','Cerrar',{left:460})", 250);
  		    		    }   		    		
	       		    },
	       		    afterrestorefunc: function(rowid) {
	       		    	lastSel = '';
	       		    },
	       		    aftersavefunc: function(rowid, response){
	       		    	lastSel = '';
	       		    	flushTblRowAdded(idTableForm, 'arrayCodProd', 2, 1, '');
	       		    	
	       		    	initialCheckGrid(arrySimula,   idTableProduct, 2, 1, 'arraySimula');
	       		    	initialCheckGrid(arryNivela,   idTableProduct, 2, 1, 'arrayNivela');
	       				initialCheckGrid(arryMultCont, idTableProduct, 2, 1, 'arrayMultCont');
	       				initialCheckGrid(arryContrata, idTableProduct, 2, 1, 'arrayContrata');
	       				
	       				recordCheckGrid(idTableProduct, arrySimula,   'codProductoHdn', 'arraySimula');
	       				recordCheckGrid(idTableProduct, arryNivela,   'codProductoHdn', 'arrayNivela');
	       				recordCheckGrid(idTableProduct, arryMultCont, 'codProductoHdn', 'arrayMultCont');
	       				recordCheckGrid(idTableProduct, arryContrata, 'codProductoHdn', 'arrayContrata');
	       		    }
	       		});
			}		
		},
		ondblClickRow: function(id, indexRow, indexCol, e){
			
			if(id && id!==lastSel){
				
				if(lastSel != ''){
		        	jQuery('#'+idTableForm).restoreRow(lastSel,true);
				}
				
		        var codProducto = document.getElementsByName("codProducto")[0];
		    	var desProducto = document.getElementsByName("desProducto")[0];
		    	
		    	if(codProducto != undefined && desProducto != undefined){
		    		if($.trim(codProducto.value) == '' || $.trim(desProducto.value) == ''){
		    			
		    			deleteTblRowAdded(idTableForm);
		    			jQuery('#'+idTableForm).jqGrid('editRow',id,
    			        { 
    	        		    keys : true,
    	        		    restoreAfterError : true,
    	        		    errorfunc: function(rowid, response) {
    	        		    	
    	       		    		var mensaje = response.responseText;
    	    		    		if (mensaje != "" && mensaje != undefined) {
    	    		    			setTimeout("alert('"+mensaje+"','Cerrar',{left:460})", 250);        		    			
    	   		    		    }else{
    	   		    		    	setTimeout("alert('Ocurrió un error al intentar guardar la información.','Cerrar',{left:460})", 250);
    	   		    		    }
    	        		    },
    	        		    afterrestorefunc: function(rowid) {
    	        		    	lastSel = '';
    	        		    },
    	        		    aftersavefunc: function(rowid, response){
    	        		    	flushTblRowEdited(idTableForm, 'arrayCodProd', 2, 1, lastSel);
    	        		    	lastSel = '';
    	        		    	
    	        		    	initialCheckGrid(arrySimula,   idTableProduct, 2, 1, 'arraySimula');
    	        		    	initialCheckGrid(arryNivela,   idTableProduct, 2, 1, 'arrayNivela');
    	        				initialCheckGrid(arryMultCont, idTableProduct, 2, 1, 'arrayMultCont');
    	        				initialCheckGrid(arryContrata, idTableProduct, 2, 1, 'arrayContrata');
    	        				
    	        				recordCheckGrid(idTableProduct, arrySimula,   'codProductoHdn', 'arraySimula');
    	        				recordCheckGrid(idTableProduct, arryNivela,   'codProductoHdn', 'arrayNivela');
    	        				recordCheckGrid(idTableProduct, arryMultCont, 'codProductoHdn', 'arrayMultCont');
    	        				recordCheckGrid(idTableProduct, arryContrata, 'codProductoHdn', 'arrayContrata');
    	        		    }
    	        		});
    			        
    			        lastSel=id;
    			        if(lastSel == 'undefined'){
    			        	lastSel = '';
    			        }    			        
		    			        
		    		}else{
		    			jQuery("#"+idTableForm).jqGrid('saveRow', "undefined",
		    			{
			       		    restoreAfterError : false,
			       		    errorfunc: function(rowid, response) {
			       		    	
			      		    	var mensaje = response.responseText;
			      		    	deleteTblRowAdded(idTableForm);
			      		    	
			   		    		if (mensaje != "" && mensaje != undefined) {
			   		    			setTimeout("alert('"+mensaje+"','Cerrar',{left:460})", 250);        		    			
		  		    		    }else{
		  		    		    	setTimeout("alert('Ocurrió un error al intentar guardar la información.','Cerrar',{left:460})", 250);
		  		    		    }   		    		
			       		    },
			       		    aftersavefunc: function(rowid, response){
			       		    	lastSel = '';
			       		    	flushTblRowAdded(idTableForm, 'arrayCodProd', 2, 1, '');
			       		    	
			       		    	initialCheckGrid(arrySimula,   idTableProduct, 2, 1, 'arraySimula');
			       		    	initialCheckGrid(arryNivela,   idTableProduct, 2, 1, 'arrayNivela');
			       				initialCheckGrid(arryMultCont, idTableProduct, 2, 1, 'arrayMultCont');
			       				initialCheckGrid(arryContrata, idTableProduct, 2, 1, 'arrayContrata');
			       				
			       				recordCheckGrid(idTableProduct, arrySimula,   'codProductoHdn', 'arraySimula');
			       				recordCheckGrid(idTableProduct, arryNivela,   'codProductoHdn', 'arrayNivela');
			       				recordCheckGrid(idTableProduct, arryMultCont, 'codProductoHdn', 'arrayMultCont');
			       				recordCheckGrid(idTableProduct, arryContrata, 'codProductoHdn', 'arrayContrata');
			       		    }
			       		});
		    		}			        
		    	}else{
		    		
		    		jQuery('#'+idTableForm).jqGrid('editRow',id,
    		        { 
            		    keys : true,
            		    restoreAfterError : true,
            		    errorfunc: function(rowid, response) {
            		    	
           		    		var mensaje = response.responseText;
        		    		if (mensaje != "" && mensaje != undefined) {
        		    			setTimeout("alert('"+mensaje+"','Cerrar',{left:460})", 250);        		    			
       		    		    }else{
       		    		    	setTimeout("alert('Ocurrió un error al intentar guardar la información.','Cerrar',{left:460})", 250);
       		    		    }
            		    },
            		    afterrestorefunc: function(rowid) {
            		    	lastSel = '';
            		    },
            		    aftersavefunc: function(rowid, response){
            		    	flushTblRowEdited(idTableForm, 'arrayCodProd', 2, 1, lastSel);
            		    	lastSel = '';
            		    	
            		    	initialCheckGrid(arrySimula,   idTableProduct, 2, 1, 'arraySimula');
            		    	initialCheckGrid(arryNivela,   idTableProduct, 2, 1, 'arrayNivela');
            				initialCheckGrid(arryMultCont, idTableProduct, 2, 1, 'arrayMultCont');
            				initialCheckGrid(arryContrata, idTableProduct, 2, 1, 'arrayContrata');
            				
            				recordCheckGrid(idTableProduct, arrySimula,   'codProductoHdn', 'arraySimula');
            				recordCheckGrid(idTableProduct, arryNivela,   'codProductoHdn', 'arrayNivela');
            				recordCheckGrid(idTableProduct, arryMultCont, 'codProductoHdn', 'arrayMultCont');
            				recordCheckGrid(idTableProduct, arryContrata, 'codProductoHdn', 'arrayContrata');
            		    }
            		});
    		        
    		        lastSel=id;
    		        if(lastSel == 'undefined'){
			        	lastSel = '';
			        }
		    	}
		    }
		},
		onPaging: function(pgButton) {
			deleteTblRowAdded(idTableForm);
        },
		editurl		: rutaContexto+'/adminForm.do?method=guardarProductoAjax',
	    caption		: "Listado de Productos",
		data 	 	: data,
		datatype 	: "local",
		height   	: "100%",
		weight 	 	: 1000,
		colNames 	: myColNames,
		colModel 	: myDataModel,
		rowList 	: [5,10,15,20,25],
		rowNum 		: 15, 
		pager 		: paginador,
		viewrecords : true,
		loadonce	: true,
		multiselect : true,			
		subGrid    	: false,
		footerrow  	: false,
		loadComplete :
           function (data) {
			
			initialCheckGrid(arrySimula,   idTableProduct, 2, 1, 'arraySimula');
			initialCheckGrid(arryNivela,   idTableProduct, 2, 1, 'arrayNivela');
			initialCheckGrid(arryMultCont, idTableProduct, 2, 1, 'arrayMultCont');
			initialCheckGrid(arryContrata, idTableProduct, 2, 1, 'arrayContrata');
			
			recordCheckGrid(idTableProduct, arrySimula,   'codProductoHdn', 'arraySimula');
			recordCheckGrid(idTableProduct, arryNivela,   'codProductoHdn', 'arrayNivela');
			recordCheckGrid(idTableProduct, arryMultCont, 'codProductoHdn', 'arrayMultCont');
			recordCheckGrid(idTableProduct, arryContrata, 'codProductoHdn', 'arrayContrata');
		}
	});
}

function mostrarTablaSegmentos(data){
	
	var idTableForm = 'listSegmentos';
	$('body').append('<div id="paginador_listSegmentos" class="grid"></div>'); 
	var paginador = "paginador_listSegmentos";
	
	jQuery("#"+idTableForm).jqGrid(
	{
		beforeSelectRow: function(){},
		afterInsertRow: function(id, rowdata, rowelem){
			
			if(id == undefined){
				jQuery("#"+idTableForm).jqGrid('editRow', id,
		        { 
	       		    keys : true,
	       		    restoreAfterError : true,
	       		    errorfunc: function(rowid, response) {
	       		    	
	      		    	var mensaje = response.responseText;
	      		    	deleteTblRowAdded(idTableForm);
	      		    	
	   		    		if (mensaje != "" && mensaje != undefined) {
	   		    			setTimeout("alert('"+mensaje+"','Cerrar',{left:460})", 250);        		    			
  		    		    }else{
  		    		    	setTimeout("alert('Ocurrió un error al intentar guardar la información.','Cerrar',{left:460})", 250);
  		    		    }   		    		
	       		    },
	       		    afterrestorefunc: function(rowid) {
	       		    	lastSelSegmento = '';
	       		    },
	       		    aftersavefunc: function(rowid, response){
	       		    	
	       		    	lastSelSegmento = '';
	       		    	flushTblRowAdded(idTableForm, 'arrayCodSegmento', 2, 1, '');
	       		    	
	       		    	initialCheckGrid(arrSegmentos, idTableSegmento, 2, 1, 'arrayCheckSegmento');
	       				recordCheckGrid(idTableSegmento, arrSegmentos, 'codSegmentoHdn', 'arrayCheckSegmento');
	       		    }
	       		});
			}		
		},
		ondblClickRow: function(id, indexRow, indexCol, e){
			
			if(id && id!==lastSelSegmento){
				
				if(lastSelSegmento != ''){
		        	jQuery('#'+idTableForm).restoreRow(lastSelSegmento,true);
				}
				
		        var codSegmento = document.getElementsByName("codSegmento")[0];
		    	var desSegmento = document.getElementsByName("desSegmento")[0];
		    	
		    	if(codSegmento != undefined && desSegmento != undefined){
		    		if($.trim(codSegmento.value) == '' || $.trim(desSegmento.value) == ''){
		    			
		    			deleteTblRowAdded(idTableForm);
		    			jQuery('#'+idTableForm).jqGrid('editRow',id,
    			        { 
    	        		    keys : true,
    	        		    restoreAfterError : true,
    	        		    errorfunc: function(rowid, response) {
    	        		    	
    	       		    		var mensaje = response.responseText;
    	    		    		if (mensaje != "" && mensaje != undefined) {
    	    		    			setTimeout("alert('"+mensaje+"','Cerrar',{left:460})", 250);        		    			
    	   		    		    }else{
    	   		    		    	setTimeout("alert('Ocurrió un error al intentar guardar la información.','Cerrar',{left:460})", 250);
    	   		    		    }
    	        		    },
    	        		    afterrestorefunc: function(rowid) {
    	        		    	lastSelSegmento = '';
    	        		    },
    	        		    aftersavefunc: function(rowid, response){
    	        		    	
    	        		    	flushTblRowEdited(idTableForm, 'arrayCodSegmento', 2, 1, lastSelSegmento);
    	        		    	lastSelSegmento = '';
    	        		    	
    	        		    	initialCheckGrid(arrSegmentos, idTableSegmento, 2, 1, 'arrayCheckSegmento');
    	        				recordCheckGrid(idTableSegmento, arrSegmentos, 'codSegmentoHdn', 'arrayCheckSegmento');
    	        		    }
    	        		});
    			        
		    			lastSelSegmento=id;
    			        if(lastSelSegmento == 'undefined'){
    			        	lastSelSegmento = '';
    			        }    			        
		    			        
		    		}else{
		    			jQuery("#"+idTableForm).jqGrid('saveRow', "undefined",
		    			{
			       		    restoreAfterError : false,
			       		    errorfunc: function(rowid, response) {
			       		    	
			      		    	var mensaje = response.responseText;
			      		    	deleteTblRowAdded(idTableForm);
			      		    	
			   		    		if (mensaje != "" && mensaje != undefined) {
			   		    			setTimeout("alert('"+mensaje+"','Cerrar',{left:460})", 250);        		    			
		  		    		    }else{
		  		    		    	setTimeout("alert('Ocurrió un error al intentar guardar la información.','Cerrar',{left:460})", 250);
		  		    		    }   		    		
			       		    },
			       		    aftersavefunc: function(rowid, response){
			       		    	
			       		    	lastSelSegmento = '';
			       		    	flushTblRowAdded(idTableForm, 'arrayCodSegmento', 2, 1, '');
			       		    	
			       		    	initialCheckGrid(arrSegmentos, idTableSegmento, 2, 1, 'arrayCheckSegmento');
			       				recordCheckGrid(idTableSegmento, arrSegmentos, 'codSegmentoHdn', 'arrayCheckSegmento');
			       		    }
			       		});
		    		}			        
		    	}else{
		    		
		    		jQuery('#'+idTableForm).jqGrid('editRow',id,
    		        { 
            		    keys : true,
            		    restoreAfterError : true,
            		    errorfunc: function(rowid, response) {
            		    	
           		    		var mensaje = response.responseText;
        		    		if (mensaje != "" && mensaje != undefined) {
        		    			setTimeout("alert('"+mensaje+"','Cerrar',{left:460})", 250);        		    			
       		    		    }else{
       		    		    	setTimeout("alert('Ocurrió un error al intentar guardar la información.','Cerrar',{left:460})", 250);
       		    		    }
            		    },
            		    afterrestorefunc: function(rowid) {
            		    	lastSelSegmento = '';
            		    },
            		    aftersavefunc: function(rowid, response){
            		    	
            		    	flushTblRowEdited(idTableForm, 'arrayCodSegmento', 2, 1, lastSelSegmento);
            		    	lastSelSegmento = '';
            		    	
            		    	initialCheckGrid(arrSegmentos, idTableSegmento, 2, 1, 'arrayCheckSegmento');
            				recordCheckGrid(idTableSegmento, arrSegmentos, 'codSegmentoHdn', 'arrayCheckSegmento');
            		    }
            		});
    		        
		    		lastSelSegmento=id;
    		        if(lastSelSegmento == 'undefined'){
    		        	lastSelSegmento = '';
			        }
		    	}
		    }
		},
		onPaging: function(pgButton) {
			deleteTblRowAdded(idTableForm);
        },
		editurl		: rutaContexto+'/adminForm.do?method=guardarSegmentoAjax',
	    caption		: "Listado de Segmentos",
		data 	 	: data,
		datatype 	: "local",
		height   	: "100%",
		weight 	 	: 1000,
		colNames 	: myColNamesSegmento,
		colModel 	: myDataModelSegmento,
		rowList 	: [5,10,15,20,25],
		rowNum 		: 15, 
		pager 		: paginador,
		viewrecords : true,
		loadonce	: true,
		multiselect : true,			
		subGrid    	: false,
		footerrow  	: false,
		loadComplete :
           function (data) {
			
			initialCheckGrid(arrSegmentos, idTableSegmento, 2, 1, 'arrayCheckSegmento');
			recordCheckGrid(idTableSegmento, arrSegmentos, 'codSegmentoHdn', 'arrayCheckSegmento');
		}
	});
}

function deleteProduct(){
	
	var selecciones = buscarSelecciones("listProducts");
	if (selecciones.length == 0){
		alert('No ha seleccionado ningún elemento para la eliminación.');
	}else{
		
		var ans = confirm('¿Esta seguro que desea eliminar los registros seleccionados?');
		if(ans){
			
			AdminAction.eliminarProductoAjax(selecciones, function(msg){
				
				var paramDelete = '';
				if(msg != ''){
					paramDelete = 'logicDelete';
				}
				
				consultarProductos(paramDelete, msg);
			});
		}
	}
}

function deleteSegmento(){
	
	var selecciones = buscarSelecciones("listSegmentos");
	if (selecciones.length == 0){
		alert('No ha seleccionado ningún elemento para la eliminación.');
	}else{
		
		var ans = confirm('¿Esta seguro que desea eliminar los registros seleccionados?');
		if(ans){
			
			AdminAction.eliminarSegmentoAjax(selecciones, function(msg){
				
				var paramDelete = '';
				if(msg != ''){
					paramDelete = 'logicDelete';
				}
				
				consultarSegmentos(paramDelete, msg);
			});
		}
	}
}

function addProduct(){
	
	var rowid = "-1";
	var mydataadd = 
		  [{
			codProductoHdn: rowid,
			codProducto  : "",
			desProducto  : "",
			nivelaOferta : "1",
			multCont	 : "1",
			simula	     : "1",
			contrata	 : "1",
			familia		 : ""
		  }];
	
	if(lastSel != ''){
		jQuery('#listProducts').restoreRow(lastSel,true);
	}
	
	lastSel = '';
	
	var codProducto = $("#undefined_codProducto");
	if(codProducto.length == 0){
		jQuery("#listProducts").addRowData(rowid, mydataadd, 'first');
	}
}

function addSegmento(){
	
	var rowid = "-1";
	var mydataadd = 
		  [{
			codSegmentoHdn: rowid,			
			codSegmento  : "",
			desSegmento  : ""	,
			seleccionSegmento : "1"
		  }];
	
	if(lastSelSegmento != ''){
		jQuery('#listSegmentos').restoreRow(lastSelSegmento,true);
	}
	
	lastSelSegmento = '';
	
	var codSegmento = $("#undefined_codSegmento");
	if(codSegmento.length == 0){
		jQuery("#listSegmentos").addRowData(rowid, mydataadd, 'first');
	}
}

function viewConfig(){
	
	var formulario = document.getElementById('formAdmin');
	var selecciones = buscarSelecciones("listProducts");
	if (selecciones.length == 0){
		alert('No ha seleccionado ningún elemento para la configuración.');
	}else {
		
		// Cuando se splitea como al inicio la cadena comienza con '**' agregara al length un elemento vacio mas
		var arrayCod = selecciones.split('**');
		if(arrayCod.length > 2){
			alert('Solo se debe seleccionar un registro para la configuración.');
		}else{
			
			formulario.action = rutaContexto+'/configProductForm.do?method=verListado&codigo='+selecciones;
			formulario.submit();
		}	
	}
}

function viewPlazo(){
	
	var formulario = document.getElementById('formAdmin');
	var selecciones = buscarSelecciones("listProducts");
	if (selecciones.length == 0){
		alert('No ha seleccionado ningún elemento para la relacion de plazos.');
	}else {
		
		// Cuando se splitea como al inicio la cadena comienza con '**' agregara al length un elemento vacio mas
		var arrayCod = selecciones.split('**');
		if(arrayCod.length > 2){
			alert('Solo se debe seleccionar un registro para la relacion de plazos.');
		}else{
			
			formulario.action = rutaContexto+'/productoPlazoForm.do?method=verListado&codigo='+selecciones;
			formulario.submit();
		}	
	}
}

function deleteIncome(codIngreso){

	var miTabla = document.getElementById("tableIncomeBody");
	var filas   = miTabla.getElementsByTagName("tr");
	
	if(filas.length > 1){
		
		// frk: en el caso que el length de los inputs sea '3'
	  	// quiere decir que es el ultimo, lo normal es '4'
		var inputs  = filas[filas.length-2].getElementsByTagName("input");
		
		var i = 0;
		var isDeleted = false;
		
		do 
			if(filas[i] != undefined){
				if(miTabla.rows.length-1 != i){
					if (""+filas[i].getElementsByTagName("input")[inputs.length-1].value == ""+codIngreso){
			            
						filas[i].style.display = "none";
						document.getElementsByName("listIngreso["+codIngreso+"].valMin")[0].value = 'delete';
						document.getElementsByName("listIngreso["+codIngreso+"].valMax")[0].value = 'delete';
						document.getElementsByName("listIngreso["+codIngreso+"].valCuota")[0].value = 'delete';
						isDeleted = true;
			        }else{ 
			            i ++;
			        }
				}else{
					isDeleted = true;
				}				
			}else{
				isDeleted = true;
			}
	        
	    while (isDeleted == false) 
	}	
}

function addRowIncome(){

	var miTabla = document.getElementById("tableIncomeBody"); 
    var fila = document.createElement("tr"); 
    var celda1 = document.createElement("td"); 
    var celda2 = document.createElement("td");
    var celda3 = document.createElement("td"); 
    var celda4 = document.createElement("td"); 
    var celda5 = document.createElement("td"); 
    var celda6 = document.createElement("td"); 
    var celda7 = document.createElement("td"); 
    
    var filas = miTabla.getElementsByTagName("tr");
    var indexFila = 0;
    
  	// frk: en el caso que el length de los inputs sea '3'
  	// quiere decir que es el ultimo, lo normal es '4'
    
    if(filas.length > 1){
    	var inputs = filas[filas.length-2].getElementsByTagName("input");
    	indexFila = parseInt(inputs[inputs.length-1].value) + 1;    	
    }
    
    celda1.innerHTML = "<font face='Arial Narrow' size='3' color='#000080'><bean:message key='label.adminform.ingreso1'/></font>"; 
    celda2.innerHTML = "<input type='text' onblur='validarNumDecimal(this);' style='text-align: right' size='10' name='listIngreso["+indexFila+"].valMin' value='' />";
    celda3.innerHTML = "<font face='Arial Narrow' size='3' color='#000080'><bean:message key='label.adminform.ingreso2'/></font>";
    celda4.innerHTML = "<input type='text' onblur='validarNumDecimal(this);' style='text-align: right' size='10' name='listIngreso["+indexFila+"].valMax' value='' />";
    celda5.innerHTML = "<font face='Arial Narrow' size='3' color='#000080'><bean:message key='label.adminform.ingreso3'/></font>";
    celda6.innerHTML = "<input type='text' onblur='validarNumPorcent(this);' style='text-align: right' size='10' name='listIngreso["+indexFila+"].valCuota' value='' />%";
    celda7.innerHTML = "<a href='javascript:deleteIncome("+indexFila+")' class='buttonOHC'>ELIMINAR</a>"+
    				   "<input type='hidden' name='contadorHidden' value='"+indexFila+"' />";
    
    fila.appendChild(celda1);
    fila.appendChild(celda2);
    fila.appendChild(celda3);
    fila.appendChild(celda4);
    fila.appendChild(celda5);
    fila.appendChild(celda6);
    fila.appendChild(celda7);
    
    miTabla.insertBefore(fila, 
   	miTabla.rows[miTabla.rows.length-1]);
}

function saveConfigurationAdmin(){
	
	var formulario = document.getElementById('formAdmin');
	var miTabla = document.getElementById("tableIncomeBody");
	var filas = miTabla.rows.length;
	var isOk = true;
	
	formulario.selSegmentos.value = '';
	for(var i=0; i<filas; i++){
		
		if(!isOk){
			break;
		}
		
		var inputs = miTabla.rows[i].getElementsByTagName("input");
		for(var z=0; z<inputs.length; z++){
			if(inputs[z].type == 'text' && inputs[z].value != 'delete' && (isNaN(inputs[z].value) || $.trim(inputs[z].value) == '')){
				alert('Debe llenar los campos de ingresos con valores numéricos');
				isOk = false;
				break;
			}		
		}
	}
	
	if(isOk){
		var codProducto = document.getElementsByName("codProducto")[0];
		var desProducto = document.getElementsByName("desProducto")[0];
		
		if((codProducto != undefined && $.trim(codProducto.value) == '') || (desProducto != undefined && $.trim(desProducto.value) == '')){
			alert('Debe llenar los datos del producto a registrar.');
			isOk = false;
		}
	}
	
	if(isOk){
		var codSegmento = document.getElementsByName("codSegmento")[0];
		var desSegmento = document.getElementsByName("desSegmento")[0];
		
		if((codSegmento != undefined && $.trim(codSegmento.value) == '') || (desSegmento != undefined && $.trim(desSegmento.value) == '')){
			alert('Debe llenar los datos del segmento a registrar.');
			isOk = false;
		}
	}
	
	if(isOk){

		var selSimula    = searchCheckGrid(arrySimula);
		var selNivela    = searchCheckGrid(arryNivela);
		var selMultCont  = searchCheckGrid(arryMultCont);
		var selContrata  = searchCheckGrid(arryContrata);
		var selSegmentos = searchCheckGrid(arrSegmentos);
		
		formulario.selSimula.value = selSimula;
		formulario.selNivela.value = selNivela;
		formulario.selMultCont.value = selMultCont;
		formulario.selContrata.value = selContrata;
		formulario.selSegmentos.value = selSegmentos;
	}
	
	if(isOk){
		
		if(formulario.allCheckSegmento.checked){
			formulario.hdnAllCheckSegmento.value = '';
		}else{
			formulario.hdnAllCheckSegmento.value = 'nothing';
		}
		
		var valorBuro = document.getElementsByName("valorBuro");
		var clasificacionBBVA = document.getElementsByName("clasificacionBBVA");
		var clasificacionSF = document.getElementsByName("clasificacionSF");
		var valorRP = document.getElementsByName("valorRP");
		
		var isBlankValorBuro = true;
		for(var z=0; z<valorBuro.length; z++){
			if(valorBuro[z].checked){
				isBlankValorBuro = false;
				break;
			}
		}
		
		var isBlankClasificacionBBVA = true;
		for(var z=0; z<clasificacionBBVA.length; z++){
			if(clasificacionBBVA[z].checked){
				isBlankClasificacionBBVA = false;
				break;
			}
		}
		
		var isBlankClasificacionSF = true;
		for(var z=0; z<clasificacionSF.length; z++){
			if(clasificacionSF[z].checked){
				isBlankClasificacionSF = false;
				break;
			}
		}
		
		var isBlankValorRP = true;
		for(var z=0; z<valorRP.length; z++){
			if(valorRP[z].checked){
				isBlankValorRP = false;
				break;
			}
		}
		
		if(isBlankValorBuro){
			formulario.hdnValorBuro.value = 'nothing';
		}else{
			formulario.hdnValorBuro.value = '';
		}
		
		if(isBlankClasificacionBBVA){
			formulario.hdnClasificacionBBVA.value = 'nothing';
		}else{
			formulario.hdnClasificacionBBVA.value = '';
		}
		
		if(isBlankClasificacionSF){
			formulario.hdnClasificacionSF.value = 'nothing';
		}else{
			formulario.hdnClasificacionSF.value = '';
		}
		
		if(isBlankValorRP){
			formulario.hdnValorRP.value = 'nothing';
		}else{
			formulario.hdnValorRP.value = '';
		}
		
		showLoading();
		formulario.action = rutaContexto+'/adminForm.do?method=saveConfigurationAdmin';
		formulario.submit();
	}
}

</script>

<body onload="closeLoading();consultarProductos('', '');consultarSegmentos('', '');">
<html:form styleId="formAdmin" method="post">

<html:hidden property="hdnValorBuro" styleId="hdnValorBuro"/>
<html:hidden property="hdnAllCheckSegmento" styleId="hdnAllCheckSegmento"/>
<html:hidden property="hdnClasificacionBBVA" styleId="hdnClasificacionBBVA"/>
<html:hidden property="hdnClasificacionSF" styleId="hdnClasificacionSF"/>
<html:hidden property="hdnValorRP" styleId="hdnValorRP"/>

<html:hidden property="seleccionados" styleId="seleccionados"/>
<html:hidden property="selSegmentos"  styleId="selSegmentos"/>
<html:hidden property="selSimula"     styleId="selSimula"/>
<html:hidden property="selNivela"     styleId="selNivela"/>
<html:hidden property="selMultCont"   styleId="selMultCont"/>
<html:hidden property="selContrata"   styleId="selContrata"/>

	<div style="background-color: #0066bb;">
		<font face="Arial Narrow" size=3 color="#FFFFFF"><b>&nbsp;
		<bean:message key="etiqueta.titleAdminSist"/>
		</b></font>
	</div>
	
	<center>
	<%
	Object messageError = request.getAttribute("messageError");
	if(messageError != null){
		if(messageError instanceof List){
			
			List listMsg = (List)messageError;
			if(!listMsg.isEmpty()){%>
				
				<div class="error">
					<% 
					for(int i = 0; i < listMsg.size(); i++){%>
						<img alt="" src="images/icono_error.png" width="17px" height="17px" class="icon">
			    		<%=listMsg.get(i)%><br/>
					<%}
					%>	
				</div>
			<%}			
			
		}else{
			if(!"".equals(messageError)){%>
				
				<div class="error">
			    	<img alt="" src="images/icono_error.png" width="17px" height="17px" class="icon">
			    	<%=messageError%><br/>
			    </div>				
			<%}
		}
	}
	%>
	

	<%
	Object messageInfo = request.getAttribute("messageInfo");
	if(messageInfo != null){
		if(messageInfo instanceof List){
			
			List listMsg = (List)messageInfo;
			if(!listMsg.isEmpty()){%>
				
				<div class="message">
					<% 
					for(int i = 0; i < listMsg.size(); i++){%>
						<img alt="" src="images/information-icon.png" width="17px" height="17px" class="icon">
			    		<%=listMsg.get(i)%><br/>
					<%}
					%>	
				</div>
			<%}			
			
		}else{
			if(!"".equals(messageInfo)){%>
				
				<div class="message">
			    	<img alt="" src="images/information-icon.png" width="17px" height="17px" class="icon">
			    	<%=messageInfo%><br/>
			    </div>				
			<%}
		}
	}
	%>
	</center>
	
	<br/>
	<%--
	<a href="javascript:saveConfigurationAdmin();"><img src="imagenes/btguardar-1.jpg" border="0"></a>
	 --%>
	<a href="javascript:saveConfigurationAdmin();" class="buttonOHC">GUARDAR</a>
	<br/><br/>
	
	<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
	
		<c:if test="${not empty command.parametros}">
			
			<tr><td>
			<font face="Arial Narrow" size=3 color="#000080"><b>
			<bean:message key="label.adminform.param1"/>:</b><br>
			<bean:message key="label.adminform.param2"/>: 
			</font><br><br>
			<div id="idSeccionClienteOfer">
			<table border="0" align="left">
			<c:set var="codTipoParametroDefault" value="-1"/>
			<c:forEach items="${command.parametros}" var="item" varStatus="status">
							
				<c:if test="${codTipoParametroDefault != command.parametros[status.index].atributo}">
					<c:set var="codTipoParametroDefault" value="${command.parametros[status.index].atributo}"/>
					<c:set var="stCabeceraDefault" value="0"/>	
				</c:if>
					
				<c:choose>
					<c:when test="${codTipoParametroDefault eq 'valorBuro'
					             or codTipoParametroDefault eq 'clasificacionBBVA'
					             or codTipoParametroDefault eq 'clasificacionSF'
					             or codTipoParametroDefault eq 'valorRP'}">						
						<c:if test="${stCabeceraDefault == '0'}">
							<tr><td align="left"><font face="Arial Narrow" size=2 color="#000080"><b><c:out value="${command.parametros[status.index].desTipoParametro}"/></b></font></td>
							<td><font face="Arial Narrow" size=2 color="#000080"><b>
						</c:if>
						
						<c:choose>
						<c:when test="${command.parametros[status.index].valParametro == 'S'}">
							<input type="checkbox" name="<c:out value="${command.parametros[status.index].atributo}"/>" 
							value="<c:out value="${command.parametros[status.index].codParametro}"/>" checked="checked">
							&nbsp;<c:out value="${command.parametros[status.index].desParametro}"/>&nbsp;&nbsp;
						</c:when>
						<c:otherwise>
							<input type="checkbox" name="<c:out value="${command.parametros[status.index].atributo}"/>" 
							value="<c:out value="${command.parametros[status.index].codParametro}"/>">
							&nbsp;<c:out value="${command.parametros[status.index].desParametro}"/>&nbsp;&nbsp;
						</c:otherwise>
						</c:choose>
						
						<c:set var="stCabeceraDefault" value="1"/>
						
						<c:choose>
						<c:when test="${command.parametros[status.index+1] != null}">
						<c:if test="${command.parametros[status.index+1].atributo != codTipoParametroDefault}">
							</b></font></td></tr>
						</c:if>	
						</c:when>
						<c:otherwise>
							</b></font></td></tr>
						</c:otherwise>
						</c:choose>				
						
					</c:when>
					<c:when test="${codTipoParametroDefault eq 'valorSE'}">
						
						<c:if test="${stCabeceraDefault == '0'}">				
							<tr><td align="left"><font face="Arial Narrow" size=2 color="#000080"><b><c:out value="${command.parametros[status.index].desTipoParametro}"/></b></font></td><td>
						</c:if>
						
						&nbsp;<input type="text" maxlength="3" onblur="validarNumPorcentInteger(this);" style="text-align: right;" name="<c:out value="${command.parametros[status.index].atributo}"/>" size="10" value="<c:out value="${command.parametros[status.index].valParametro}"/>" />
						<c:out value="${command.parametros[status.index].desParametro}"/>
						
						<c:set var="stCabeceraDefault" value="1"/>
						
						<c:choose>
						<c:when test="${command.parametros[status.index+1] != null}">
						<c:if test="${command.parametros[status.index+1].atributo != codTipoParametroDefault}">
							</td></tr>
						</c:if>	
						</c:when>
						<c:otherwise>
							</td></tr>
						</c:otherwise>
						</c:choose>
						
					</c:when>
				</c:choose>
	
		  	</c:forEach>
		  	</table>
		  	</div>
			</td></tr>
			
			<tr><td>&nbsp;</td></tr>
			
		</c:if>
	 
		<tr><td>
		
			<font face="Arial Narrow" size="3" color="#000080"><b>
			<bean:message key="label.adminform.ingresos"/>:
			</b></font><br/>
			
			<%--
			<a href="javascript:addRowIncome();"><img src="imagenes/btagrega-1.jpg" border="0"></a>
			 --%>
			 
			<a href="javascript:addRowIncome();" class="buttonOHC">AGREGAR</a>
			<br/>
				
			<table id="tableIncome">
			<tbody id="tableIncomeBody">
			
			<c:choose>
			<c:when test="${not empty command.ingresos}">
				<c:forEach items="${command.ingresos}" var="item" varStatus="status">
					
					<c:if test="${command.ingresos[status.index].numMax != null and command.ingresos[status.index].valMax != 'delete'}">
						
						<tr>
						<td><font face="Arial Narrow" size="3" color="#000080">
						<bean:message key="label.adminform.ingreso1"/></font></td>
					
						<td><input type="text" onblur="validarNumDecimal(this);" 
						style="text-align: right" size="10" 
						name="listIngreso[<c:out value="${status.index}"/>].valMin" 
						value="<c:out value="${command.ingresos[status.index].numMin}"/>" /></td>
					
						<td><font face="Arial Narrow" size="3" color="#000080">
						<bean:message key="label.adminform.ingreso2"/></font></td>
						
						<td><input type="text" onblur="validarNumDecimal(this);" 
						style="text-align: right" size="10" 
						name="listIngreso[<c:out value="${status.index}"/>].valMax" 
						value="<c:out value="${command.ingresos[status.index].numMax}"/>" /></td>
						
						<td><font face="Arial Narrow" size="3" color="#000080">
						<bean:message key="label.adminform.ingreso3"/></font></td>
					
						<td><input type="text" onblur="validarNumPorcent(this);" 
						style="text-align: right" size="10" 
						name="listIngreso[<c:out value="${status.index}"/>].valCuota" 
						value="<c:out value="${command.ingresos[status.index].numCuota}"/>" />%</td>
						
						<td>
						<%-- 
						<a href="javascript:deleteIncome('${status.count-1}');"><img src="imagenes/btelimina-1.jpg" border="0"></a>
						 --%>
						
						<a href="javascript:deleteIncome('${status.count-1}');" class="buttonOHC">ELIMINAR</a>
						
						<input type="hidden" name="contadorHidden" value="${status.count-1}" />
						</td>
						</tr>
						
					</c:if>
					
					<c:if test="${status.count == command.sizeIngresos}">
						
						<tr>
						<td><font face="Arial Narrow" size="3" color="#000080">
						<bean:message key="label.adminform.ingreso1"/></font></td>
					
						<td><input type="text" onblur="validarNumDecimal(this);" 
						style="text-align: right" size="10" name="listIngreso[0].valMinFinal" 
						value="<c:out value="${command.ingresos[0].numMinFinal}"/>" /></td>
					
						<td>&nbsp;</td>
						<td><input type="hidden" name="listIngreso[0].valMaxFinal" /></td>
						
						<td><font face="Arial Narrow" size="3" color="#000080">
						<bean:message key="label.adminform.ingreso3"/></font></td>
					
						<td><input type="text" onblur="validarNumPorcent(this);" 
						style="text-align: right" size="10" name="listIngreso[0].valCuotaFinal" 
						value="<c:out value="${command.ingresos[0].numCuotaFinal}"/>" />%</td>
						
						<td>&nbsp;</td>
						</tr>
						
					</c:if>
					
				</c:forEach>
			</c:when>
			<c:otherwise>
				
				<tr>
				<td><font face="Arial Narrow" size="3" color="#000080">
				<bean:message key="label.adminform.ingreso1"/></font></td>
				
				<td><input type="text" onblur="validarNumDecimal(this);" style="text-align: right" size="10" name="listIngreso[0].valMinFinal" value="0.00" /></td>
				
				<td>&nbsp;</td>
				
				<td><input type="hidden" name="listIngreso[0].valMaxFinal" /></td>
				
				<td><font face="Arial Narrow" size="3" color="#000080">
				<bean:message key="label.adminform.ingreso3"/></font></td>
				
				<td><input type="text" onblur="validarNumPorcent(this);" style="text-align: right" size="10" name="listIngreso[0].valCuotaFinal" value="0" />%</td>
				
				<td>&nbsp;</td>
				</tr>
				
			</c:otherwise>
			</c:choose>
			
			</tbody>
			</table>
				
		</td></tr>
		
		<tr><td>&nbsp;</td></tr>
		
		<tr><td>
		<table>
		<tr>
		<td><font face="Arial Narrow" size=3 color="#000080">Ignorar los segmentos:</font></td>
		<td>
		
		<c:choose>
		<c:when test="${command.allCheckSegmento eq 'S'}">
			<input type='checkbox' name='allCheckSegmento' id='allCheckSegmento' value='S' checked="checked" />
		</c:when>
		<c:otherwise>
			<input type='checkbox' name='allCheckSegmento' id='allCheckSegmento' value='S' />
		</c:otherwise>
		</c:choose>
		
		</td>
		</tr>
		</table>
		
		</td></tr>
		<tr><td>
		
	 	<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
		<td><font face="Arial Narrow" size=3 color="#000080">	
			Si el Cliente pertenece al Segmento:</font><br/>
			
			<%--
			<a href="javascript:deleteSegmento();"><img src="imagenes/btelimina-1.jpg" border="0"></a>&nbsp;
			<a href="javascript:addSegmento();"><img src="imagenes/btagrega-1.jpg" border="0"></a>
			 --%>
			 
			<a href="javascript:deleteSegmento();" class="buttonOHC">ELIMINAR</a>&nbsp;
			<a href="javascript:addSegmento();" class="buttonOHC">AGREGAR</a>
			<br><br>
			
	 		<table id="listSegmentos" class="grid">
			</table>
	 		
	 	</td>
		</tr>
		</table>
		
		</td></tr>
		
		<tr><td>&nbsp;</td></tr>
		
		<tr><td>
		
			<font face="Arial Narrow" size=3 color="#000080"><b>
			<bean:message key="label.adminform.product1"/></b><br/>
			<bean:message key="label.adminform.product2"/>:
			</font><br><br>
			
			<%--
			<a href="javascript:deleteProduct();"><img src="imagenes/btelimina-1.jpg" border="0"></a>&nbsp;
			<a href="javascript:addProduct();"><img src="imagenes/btagrega-1.jpg" border="0"></a>&nbsp;
			<a href="javascript:viewPlazo();"><img src="imagenes/btplazo-1.jpg" border="0"></a>&nbsp;
			<a href="javascript:viewConfig();"><img src="imagenes/btconfigurar-1.jpg" border="0"></a>
			 --%>
			 
			<a href="javascript:deleteProduct();" class="buttonOHC">ELIMINAR</a>&nbsp;
			<a href="javascript:addProduct();" class="buttonOHC">AGREGAR</a>&nbsp;
			<a href="javascript:viewPlazo();" class="buttonOHC">PLAZOS</a>&nbsp;
			<a href="javascript:viewConfig();" class="buttonOHC">CONFIGURAR</a>
			
			<br><br>
			
			<table id="listProducts" class="grid">
			</table>
			
		</td></tr>
		
	</table>
	
	<br/>
	<%--
	<a href="javascript:saveConfigurationAdmin();"><img src="imagenes/btguardar-1.jpg" border="0"></a>
	 --%>
	<a href="javascript:saveConfigurationAdmin();" class="buttonOHC">GUARDAR</a>
	
	<script language="JavaScript">	
		document.getElementById("idSeccionClienteOfer").disabled = true;			
	</script>
	
</html:form>
</body>
</html>